Array Destructuring Tasks - Task 02

Swap Variables

Use array destructuring to swap a and b.

// 2. Swap Variables
// Use array destructuring to swap a and b.

let a = 5;
let b = 10;

console.log("~ Before swaping")
console.log("a - " + a);
console.log("b - " + b);

// using destructuring
[a , b] = [10, 5];

console.log("~ After swaping")
console.log("a - " + a);
console.log("b - " + b);